]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
swipeTracker: Add allowLongSwipes property
authorAlexander Mikhaylenko <exalm7659@gmail.com>
Sun, 7 Feb 2021 20:02:58 +0000 (01:02 +0500)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Mon, 8 Feb 2021 22:20:26 +0000 (22:20 +0000)
Since we now have the ability to support swiping through multiple pages,
expose it as a property.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1647>

js/ui/swipeTracker.js

index e31bf372a6ad3b262023268f385ce46ac55d04d3..7bd4a96bd7261f06ce6eab72e097114a9774ada1 100644 (file)
@@ -389,6 +389,10 @@ var SwipeTracker = GObject.registerClass({
             'distance', 'distance', 'distance',
             GObject.ParamFlags.READWRITE,
             0, Infinity, 0),
+        'allow-long-swipes': GObject.ParamSpec.boolean(
+            'allow-long-swipes', 'allow-long-swipes', 'allow-long-swipes',
+            GObject.ParamFlags.READWRITE,
+            false),
         'scroll-modifiers': GObject.ParamSpec.flags(
             'scroll-modifiers', 'scroll-modifiers', 'scroll-modifiers',
             GObject.ParamFlags.READWRITE,
@@ -406,6 +410,7 @@ var SwipeTracker = GObject.registerClass({
 
         this._allowedModes = allowedModes;
         this._enabled = true;
+        this._allowLongSwipes = false;
         this._distance = global.screen_height;
         this._history = new EventHistory();
         this._reset();
@@ -597,8 +602,11 @@ var SwipeTracker = GObject.registerClass({
         this._progress += delta / distance;
         this._history.append(time, delta);
 
-        this._progress = Math.clamp(this._progress,
-            ...this._getBounds(this._initialProgress));
+        const [lower, upper] = this.allowLongSwipes
+            ? [this._snapPoints[0], this._snapPoints[this._snapPoints.length - 1]]
+            : this._getBounds(this._initialProgress);
+
+        this._progress = Math.clamp(this._progress, lower, upper);
 
         this.emit('update', this._progress);
     }
@@ -628,7 +636,9 @@ var SwipeTracker = GObject.registerClass({
         }
 
         pos = pos * Math.sign(velocity) + this._progress;
-        pos = Math.clamp(pos, ...this._getBounds(this._initialProgress));
+
+        if (!this.allowLongSwipes)
+            pos = Math.clamp(pos, ...this._getBounds(this._initialProgress));
 
         const index = this._findPointForProjection(pos, velocity);